home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / QuickDraw3D 1.6 SDK / Mac SampleCode New for 1.6 / FogStyleSample / Source / Menus.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-18  |  3.0 KB  |  194 lines  |  [TEXT/CWIE]

  1. /****************************/
  2. /*        MENUS             */
  3. /****************************/
  4.  
  5.  
  6. /***************/
  7. /* EXTERNALS   */
  8. /***************/
  9. #include <ToolUtils.h>
  10.  
  11.  
  12. #include "myglobals.h"
  13. #include "qd3d_support.h"
  14. #include "mymenus.h"
  15. #include "misc.h"
  16. #include "process.h"
  17. #include "3dmf.h"
  18.  
  19. extern    QD3DSetupOutputType    gModelViewInfo;
  20.  
  21.  
  22. /******************/
  23. /*  PROTOTYPES    */
  24. /******************/
  25.  
  26. static void HandleSpecialMenuChoice(short theItem);
  27.  
  28.  
  29. /****************************/
  30. /*    CONSTANTS             */
  31. /****************************/
  32.  
  33.                                     // MENU BAR ITEMS //
  34. #define    NOT_A_NORMAL_MENU    -1
  35. #define    APPLE_MENU_ID        400
  36. #define    FILE_MENU_ID        401
  37. #define EDIT_MENU_ID        402
  38.  
  39.  
  40.                                     // EDIT MENU ITEMS //
  41.                                     
  42. enum
  43. {
  44.     UNDO_ITEM    =    1,
  45.     CUT_ITEM    =    3,
  46.     COPY_ITEM    =    4,    
  47.     PASTE_ITEM    =    5,
  48.     CLEAR_ITEM    =    6
  49. };
  50.  
  51.                                     // FILE MENU ITEMS //
  52. enum
  53. {
  54.     SAVE_ITEM    = 1,
  55.     QUIT_ITEM    = 2
  56. };
  57.  
  58.  
  59.                                     // APPLE MENU ITEMS //
  60. enum                                    
  61. {                                    
  62.     ABOUT_ITEM = 1,
  63.     HELP_ITEM = 2
  64. };
  65.  
  66.  
  67.  
  68. /**********************/
  69. /*     VARIABLES      */
  70. /**********************/
  71.  
  72. MenuHandle    gAppleMenu;
  73.  
  74.  
  75. /******************/
  76. /* INIT MENU BAR  */
  77. /******************/
  78.  
  79. void InitMenuBar(void)
  80. {
  81. Handle    myMenuBar;
  82.         
  83.                     /* ALLOCATE MAIN MENU BAR */
  84.     
  85.     if ((myMenuBar    =    GetNewMBar(400)) == nil)
  86.             DoFatalAlert("\pWhered the menu bar go?!");;
  87.     SetMenuBar(myMenuBar);
  88.     
  89.                     /* SET APPLE MENU */
  90.  
  91.     if ((gAppleMenu    =    GetMenuHandle(400)) == nil)
  92.             DoFatalAlert("\pGetMHandle failed!");
  93.     AppendResMenu (gAppleMenu, 'DRVR');                        // APPEND DESK ACCESSORIES
  94.     
  95.     DrawMenuBar();
  96. }
  97.  
  98.  
  99. /***************************/
  100. /* HANDLE MENU BAR CHOICE  */
  101. /***************************/
  102.  
  103. void HandleMenuChoice(long menuChoice)
  104. {
  105. short    theMenu;
  106. short    theItem;
  107.         
  108.     if    (menuChoice != 0)
  109.     {
  110.         theMenu    =    HiWord(menuChoice);
  111.         theItem    =    LoWord(menuChoice);
  112.         switch    (theMenu)
  113.         {
  114.             case    APPLE_MENU_ID:
  115.                     HandleAppleChoice(theItem);
  116.                     break;
  117.                     
  118.             case    FILE_MENU_ID:
  119.                     HandleFileChoice(theItem);
  120.                     break;
  121.                     
  122.             case    EDIT_MENU_ID:
  123.                     HandleEditChoice(theItem);
  124.                     break;
  125.                     
  126.                     
  127.         }
  128.         HiliteMenu(0);
  129.     }
  130. }
  131.  
  132.  
  133. /*****************************/
  134. /* HANDLE APPLE MENU CHOICE  */
  135. /*****************************/
  136.  
  137. void HandleAppleChoice(short theItem)
  138. {
  139. Str255    accName;
  140. short        accNumber;
  141.         
  142.     switch    (theItem)
  143.     {
  144.         case    ABOUT_ITEM:
  145.         
  146.                 Alert(402,nil);
  147.                 break;
  148.         case    HELP_ITEM:
  149.                 Alert(128,nil);
  150.                 break;
  151.             
  152.         default:
  153.                 GetMenuItemText(gAppleMenu,theItem,accName);
  154.                 accNumber    =    OpenDeskAcc(accName);
  155.                 break;
  156.     }
  157. }
  158.  
  159. /****************************/
  160. /* HANDLE FILE MENU CHOICE  */
  161. /****************************/
  162.  
  163. void HandleFileChoice(short theItem)
  164. {
  165.     switch(theItem)
  166.     {
  167.         case    QUIT_ITEM:
  168.                 QD3D_DisposeWindowSetup(&gModelViewInfo);
  169.                 DisposeWindow(gModelViewInfo.window);
  170.                 CleanQuit();
  171.                 
  172.         case    SAVE_ITEM:
  173.                 Save3DMFModel(&gModelViewInfo,nil,SubmitFogAndGeometry);
  174.                 break;
  175.     }
  176. }
  177.  
  178.  
  179. /****************************/
  180. /* HANDLE EDIT MENU CHOICE  */
  181. /****************************/
  182.  
  183. void HandleEditChoice(short theItem)
  184. {
  185.     SystemEdit(theItem-1);
  186.         
  187.     switch(theItem)
  188.     {
  189.     }
  190. }
  191.  
  192.  
  193.  
  194.